
package linuxbox.admin.bean;

import java.util.*;

import linuxbox.util.*;
import linuxbox.admin.logic.*;
import linuxbox.admin.exception.*;

public class DeptHome {
	private	DbAdapter m_db = null;
	private	boolean m_bTransaction = false;
	
	public DeptHome() {
		m_db = null;
		m_bTransaction = false;
	}
	
	public DeptHome(DbAdapter db) {
		m_db = db;
		m_bTransaction = true;
	}

	public DeptKey create(Department dept) throws DeptBeanException {
		DeptBean bean = null;

		if (m_bTransaction)
			bean = new DeptBean(null, m_db);
		else
			bean = new DeptBean(null);
			
		return bean.create(dept);
	}

	public void remove(DeptKey pk) throws DeptBeanException {
		DeptBean bean = null;

		if (m_bTransaction)
			bean = new DeptBean(pk, m_db);
		else
			bean = new DeptBean(pk);
		bean.remove();
	}

	public DeptKey findByKey(DeptKey pk) throws DeptBeanException {
		DeptBean bean = null;

		if (m_bTransaction)
			bean = new DeptBean(pk, m_db);
		else
			bean = new DeptBean(pk);

		return bean.findByKey();
	}

	public ArrayList findBySql(String sqlWhere) throws DeptBeanException {
		DeptBean bean = null;

		if (m_bTransaction)
			bean = new DeptBean(null, m_db);
		else
			bean = new DeptBean(null);

		return bean.findBySql(sqlWhere);
	}
}